﻿import mx.utils.Delegate;

import com.mixmedia.motion.MotionTween;
import com.mixmedia.mx.Event;
/**
 * @author colin
 */
class com.mixmedia.control.CrossFadeDescription extends MovieClip {
	private var motion:MotionTween;
	private var mcMsg : MovieClip;
	private var delFadeOut : Function;

	private var currentSection : String;
	
	public function CrossFadeDescription(){
		mcMsg._alpha = 0;
		motion = new MotionTween(mcMsg,{dur:5});
		motion.startTween({a:100});
		delFadeOut = Delegate.create(this,onFadeOut);
	}

	public function swapSection(arg:String){
		currentSection = arg;
		motion.addEventListener(Event.TWEENEND,delFadeOut);
		motion.startTween({a:0});
	}
	
	private function onFadeOut(){
		motion.removeEventListener(Event.TWEENEND,delFadeOut);
		mcMsg.gotoAndPlay('m'+currentSection);
		motion.startTween({a:100});
	}
}